package com.benmei.ntlive.vo;

import io.netty.channel.Channel;

/**
 * Created by Peter on 2017/9/7.
 */
public class Session {
    private Channel channel;
    private User user;

    public Session(Channel channel, User user) {
        this.channel = channel;
        this.user = user;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Session session = (Session) o;

        return channel != null ? channel.remoteAddress().toString().equals(session.channel.remoteAddress().toString()) : session.channel == null;
    }

    @Override
    public int hashCode() {
        return channel != null ? channel.hashCode() : 0;
    }
}
